<script type="text/javascript" src="/js/shoppingcart.js" language="javascript" ></script>
<?php 
if(isset($_SESSION['config_template']))
{
	if($_SESSION['config_template']=='layoutmain_web1')
	{?>
<div class="col-main" id="main">
					<!-- start global messages -->
					<!-- end global messages -->
					<!-- start content -->
					<div class="page-head-alt button-level">
							<h3><?php echo $this->text_title;?></h3>
						</div>
						<form method="post" action="#link update">
							<table cellspacing="0" border="0" class="data-table box-table shopping-cart" id="shopping-cart-table">
							<colgroup>
								<col width="40">
								<col width="75">
								<col>
								<col width="80">
								<col width="1">
								<col width="80">
							</colgroup>
							<?php
							$subTotal=0;
							if(isset($this->cart))
							{
								if($this->cart==0)
								{
								?>
									<tr class="cart_content"><td align="center" valign="center" colspan="7"><?php echo $this->text_empty;?></td></tr>
								<?php
								} else	{ 
									if(is_array($this->cart))
									{ ?>
							<thead>
								<tr class="first last">
									<th rowspan="1">
										<?php echo $this->text_no;?>
										<br><input type="checkbox" name="chBAll" id="chBAll" class="checkBox" onclick="checkAll()" style="margin-left:20%;margin-right:20%;width:50%;"/>
									</th>
									<th rowspan="1"><?php echo $this->text_image;?></th>
									<th rowspan="1"><?php echo $this->text_name;?></th>
									<th colspan="1" class="a-center"><?php echo $this->text_price;?></th>
									<th class="a-center" rowspan="1"><?php echo $this->text_quan;?></th>
									<th colspan="1" class="a-center"><?php echo $this->text_total;?></th>
									<th colspan="1" class="a-center"><?php echo $this->text_act;?></th>
								</tr>
							</thead>
							<tfoot style="border-top-color:gray;border-top-style: solid;border-top-width: 1px;">
								<tr class="first last">
									<td class="a-right" colspan="4">
										&nbsp;
										
										
										<button class="form-button-alt" name="btnCheckout" onclick="javascript:window.location='/cart/payment?step=1'" type="button" style="float:right">
											<span style="line-height: 20px"><?php echo $this->text_check;?></span>
										</button>
										<button class="form-button-alt" name="btnReCal" type="submit" style="float:right">
											<span style="line-height: 20px"><?php echo $this->text_recal;?></span>
										</button>
										<button class="form-button-alt" name="btnDel" onclick="return optionalDelele('<?php echo $this->confirm;?>')" type="submit" style="float:right">
											<span style="line-height: 20px"><?php echo $this->text_del;?></span>
										</button>
										
									</td>
									<td style="border-top:1px solid #d9dde3 !important;background:white">
										<b><?php echo $this->text_subtotal;?>:</b>
									</td>
									<?php foreach($this->cart as $id=>$qty)
									{
										$cartProduct=0;
										foreach($this->Products as $product)
										{
											if($product["thing_id"]==$id)
											{
												$cartProduct=$product;
												break;
											}
										}
										$subTotal+=$qty*$cartProduct["price"];
									}
									?>
									<td style="border-top:1px solid #d9dde3 !important;background:white" class="last">
										<b><?php echo number_format($subTotal)." VND" ?></b>
									</td>
								</tr>
							</tfoot>
							<tbody>		
							<?php 
								$count=0;
								foreach($this->cart as $id=>$qty)
								{
								$count++;
								$cartProduct=0;
									foreach($this->Products as $product)
									{
										if($product["thing_id"]==$id)
										{
											$cartProduct=$product;
											break;
										}
									}
									$subTotal+=$qty*$cartProduct["price"];
								?>
							
									<tr class="first odd">
									
										<td>
											<div style="font-weight:bold; font-size:16px;width:50%;margin-left:20%;margin-right:20%;"><?php echo $count ?></div>
											<div style="margin-top:5px;width:50%;margin-left:20%;margin-right:20%;"><input type="checkbox" name="chB<?php echo $id ?>" class="checkBox" onclick="check()" /></div>
										</td>
										<td><img src="<?php echo $cartProduct["avatar"]?>" alt="" width="100" height="100" /></td>
										<td class="attributes-col">
											<h4 class="title"><a href="/index/detail?id=<?php echo $id;?>"><?php echo $cartProduct["title"]?></a></h4>
										</td>
										<td class="a-right">
											<div class="cart-price">
												<span class="price"><?php echo number_format($cartProduct["price"])." VND" ?></span>            
											</div>
										</td>
										<td class="a-center">
											<input type="text" name="quantity[<?php echo $id ?>]" value="<?php echo $qty ?>" size="3" maxlength="2"/>
										</td>
										<td class="a-right ">
											<div class="cart-price">
												<span class="price"><?php echo number_format($qty*$cartProduct["price"])." VND" ?></span>            
											</div>
										</td>
										<td class="a-center last" >
										<button style="background-image: url('/images/web1/btn_trash.gif');width:16px;height:16px;border:none " onclick="return delLinkClick(this,<?php echo $id ?>,'<?php echo $this->confirm;?>')" name="delete" type="submit" style="float:right">
											
										</button>
										
										</td>	
									</tr>        
							<?php }}}}?>  
							</tbody>  
							</table>
									<!--<a id="delBtnlink" href="/shoppingcart/index"><input type="button" name="btnDel" value="Delete" class="cart_button" /></a>-->
																	     
						</form>
						<div style="clear:both; height:20px;"></div>
						<!-- end table checkout -->
					<!-- end content -->
					</div>		
	<?php 
	}
	else if ($_SESSION['config_template']=='layoutmain_web2')
	{?>
		
	
	
	<div class="page-title">
    <h1><?php echo $this->text_title;?></h1>
</div>
<form form name="cartForm" action="/cart/index" method="post">
<table cellspacing="0" border="0" class="data-table box-table shopping-cart" id="shopping-cart-table">
    <?php
		$subTotal=0;
		if(isset($this->cart))
		{
			if($this->cart==0)
			{
	?>
		<td align="center" valign="center" colspan="7"><p><?php echo $this->text_empty;?></p></td>
	<?php
			} else
			{ 
				if(is_array($this->cart))
				{ ?>
	
	<colgroup>
		<col width="15">
		<col width="40">
		<col width="75">
		<col>
		<col width="80">
		<col width="1">
		<col width="80">
	</colgroup>
	
	<thead>
        <tr class="first last">
			<th class="a-center">
				<?php echo $this->text_no;?>
				<br><input type="checkbox" name="chBAll" id="chBAll" class="checkBox" onclick="checkAll()"/>
			</th>
            <th class="a-center" rowspan="1"><?php echo $this->text_act;?></th>
            <th class="a-center" rowspan="1"><?php echo $this->text_image;?></th>
            <th rowspan="1"><?php echo $this->text_name;?></th>
                        <th colspan="1" class="a-center"><?php echo $this->text_price;?></th>
            <th class="a-center" rowspan="1"><?php echo $this->text_quan;?></th>
            <th colspan="1" class="a-center"><?php echo $this->text_total;?></th>
        </tr>
    </thead>
	
    <tfoot>
        <tr class="first last">
            <td class="a-right last" colspan="100">
                <button type="submit" class="form-button-alt" onclick="return optionalDelele('<?php echo $this->confirm;?>')"><span><?php echo $this->text_del;?></span></button>
				<button type="submit" class="form-button-alt"><span><?php echo $this->text_recal;?></span></button>
				<button type="button" class="form-button-alt" onclick="javascript:window.location='/cart/payment?step=1'"><span><?php echo $this->text_check;?></span></button>
            </td>
        </tr>
    </tfoot>
	<?php 
								$count=0;
								foreach($this->cart as $id=>$qty)
								{
								$count++;
								$cartProduct=0;
									foreach($this->Products as $product)
									{
										if($product["thing_id"]==$id)
										{
											$cartProduct=$product;
											break;
										}
									}
				?>
	
    <tbody>
        <tr class="first odd">
			<td class="a-center">
				<?php echo $count ?>
				<br><input type="checkbox" name="chB<?php echo $id ?>" class="checkBox" onclick="check()" />
			</td>
			<td class="a-center">
				<button style="background-image: url('/images/web1/btn_trash.gif');width:16px;height:16px;border:none " onclick="return delLinkClick(this,<?php echo $id ?>,'<?php echo $this->confirm;?>')" name="delete" type="submit" style="float:right">
				</button>
				
			</td>
			<td><img height="75" width="75" alt="Computer" src="<?php echo $cartProduct["avatar"]?>"></td>
			<td>
				<h2 class="product-name">
                    <a href="/index/detail?id=<?php echo $id;?>"><?php echo $cartProduct["title"]?>
                </h2>
                
            </td>
            <td class="a-right">
                <span class="cart-price">
					<span class="price"><?php echo number_format($cartProduct["price"])." VND" ?></span>            
				</span>
            </td>
            <td class="a-center">
				<input type="text" maxlength="2" class="input-text qty" title="Qty" size="3" value="<?php echo $qty ?>" name="quantity[<?php echo $id ?>]">
			</td>
			<td class="a-right last">
                <span class="cart-price">
					<span class="price"><?php echo number_format($qty*$cartProduct["price"])." VND" ?></span>            
				</span>
            </td>
        </tr>
	<?php
									$subTotal+=$qty*$cartProduct["price"];
								}
				?>
		<tr class="first last odd">
			<td colspan="6" style="text-align:right; font-size:15px;font-weight:bold">
				<?php echo $this->text_subtotal;?>:
			</td>
			<td>
				<b style="color:red"><?php echo number_format($subTotal)." VND" ?></b>
			</td>
		</tr>
    </tbody>
	<?php
							}
						}
					}
				?>
</table>
<script type="text/javascript">decorateTable('shopping-cart-table')</script>
</form>
	
	<?php } else{?>
		<p><?php echo $this->text_title;?></p>
	<div class="line"><hr></div>
			<div style="clear: both;"></div>
			<form name="cartForm" action="/cart/index" method="post">
			
				<table class="shoppingcart" border="1" cellpadding="2" cellspacing="0"><!--Shopping Cart-->
				
				<?php
					$subTotal=0;
					if(isset($this->cart))
					{
						if($this->cart==0)
						{
				?>
					<tr class="cart_content"><td align="center" valign="center" colspan="7"><?php echo $this->text_empty;?></td></tr>
				<?php
						} else
						{ 
							if(is_array($this->cart))
							{ ?>
						<tr style="height:40px;vertical-align: top;"><!--Headers-->
							<th class="No" width="40">
							<div><?php echo $this->text_no;?></div>
							<div><input type="checkbox" name="chBAll" id="chBAll" class="checkBox" onclick="checkAll()"/></div>
							</th>
							<th  width="120"><?php echo $this->text_image;?></th>
							<th class="Name" width="220"><?php echo $this->text_name;?></th>
							<th class="Price" width="100"><?php echo $this->text_price;?></th>
							<th class="Quantity" width="80"><?php echo $this->text_quan;?></th>
							<th class="Total" width="100"><?php echo $this->text_total;?></th>
							<th class="Action"width="80"><?php echo $this->text_act;?></th>
						</tr>
							<?php 
								$count=0;
								foreach($this->cart as $id=>$qty)
								{
								$count++;
								$cartProduct=0;
									foreach($this->Products as $product)
									{
										if($product["thing_id"]==$id)
										{
											$cartProduct=$product;
											break;
										}
									}
								?>
									<tr class="cart_content"><!--content 1st-->
										<td align="center" valign="top">
											<div style="font-weight:bold; font-size:16px"><?php echo $count ?></div>
											<div style="margin-top:10px;"><input type="checkbox" name="chB<?php echo $id ?>" class="checkBox" onclick="check()" /></div>
										</td>
										<td align="center" valign="top"><img src="<?php echo $cartProduct["avatar"]?>" alt="" width="100" height="100" /></td>
										<td align="center" valign="top"><a href="/index/detail?id=<?php echo $id;?>"><?php echo $cartProduct["title"]?></a></td>
										<td align="center" valign="top" style="font-size:11px;"><?php echo number_format($cartProduct["price"])." VND" ?></td>
										<td align="center" valign="top"><input type="text" name="quantity[<?php echo $id ?>]" value="<?php echo $qty ?>" size="3" maxlength="2"/></td>
										<td align="center" valign="top" style="font-size:11px;"><?php echo number_format($qty*$cartProduct["price"])." VND" ?></td>
										<!--
										<td align="center" valign="top"><a href="/shoppingcart/index?DelProduct=<?php //echo $cartProduct["thing_id"] ?>">delete</a></td>
										-->
										<td align="center" valign="top" ><input type="submit" name="delete" onclick="return delLinkClick(this,<?php echo $id ?>,'<?php echo $this->confirm;?>')" value="<?php echo $this->text_del;?>" style="font-family:arial; font-size=10px;" /></td>	
									</tr>
				<?php
									$subTotal+=$qty*$cartProduct["price"];
								}
				?>
				<tr style="height:40px;"><!--Bottom-->
					<th colspan="4">
						<!--<a id="delBtnlink" href="/shoppingcart/index"><input type="button" name="btnDel" value="Delete" class="cart_button" /></a>-->
						<input type="submit" name="btnDel" value="<?php echo $this->text_del;?>" class="cart_button" onclick="return optionalDelele('<?php echo $this->confirm;?>')" />
						<input type="submit" name="btnReCal" value="<?php echo $this->text_recal;?>" class="cart_button" />
						<input type="button" onclick="javascript:window.location='/cart/payment?step=1'" name="btnCheckout" value="<?php echo $this->text_check;?>" class="cart_button" />
					</th>
					<th><?php echo $this->text_subtotal;?>:</th>
					<th style="font-size:11px;"><?php echo number_format($subTotal)." VND" ?></th>
					<th>&nbsp;</th>
				</tr>
				<?php
							}
						}
					}
				?>
				
				
				</table>
				
			</form>
				<div style="clear: both;"></div>
				<?php }}  else {?>
		<p><?php echo $this->text_title;?></p>
	<div class="line"><hr></div>
			<div style="clear: both;"></div>
			<form name="cartForm" action="/cart/index" method="post">
			
				<table class="shoppingcart" border="1" cellpadding="2" cellspacing="0"><!--Shopping Cart-->
				
				<?php
					$subTotal=0;
					if(isset($this->cart))
					{
						if($this->cart==0)
						{
				?>
					<tr class="cart_content"><td align="center" valign="center" colspan="7"><?php echo $this->text_empty;?></td></tr>
				<?php
						} else
						{ 
							if(is_array($this->cart))
							{ ?>
						<tr style="height:40px;vertical-align: top;"><!--Headers-->
							<th class="No" width="40">
							<div><?php echo $this->text_no;?></div>
							<div><input type="checkbox" name="chBAll" id="chBAll" class="checkBox" onclick="checkAll()"/></div>
							</th>
							<th  width="120"><?php echo $this->text_image;?></th>
							<th class="Name" width="220"><?php echo $this->text_name;?></th>
							<th class="Price" width="100"><?php echo $this->text_price;?></th>
							<th class="Quantity" width="80"><?php echo $this->text_quan;?></th>
							<th class="Total" width="100"><?php echo $this->text_total;?></th>
							<th class="Action"width="80"><?php echo $this->text_act;?></th>
						</tr>
							<?php 
								$count=0;
								foreach($this->cart as $id=>$qty)
								{
								$count++;
								$cartProduct=0;
									foreach($this->Products as $product)
									{
										if($product["thing_id"]==$id)
										{
											$cartProduct=$product;
											break;
										}
									}
				?>
									<tr class="cart_content"><!--content 1st-->
										<td align="center" valign="top">
											<div style="font-weight:bold; font-size:16px"><?php echo $count ?></div>
											<div style="margin-top:10px;"><input type="checkbox" name="chB<?php echo $id ?>" class="checkBox" onclick="check()" /></div>
										</td>
										<td align="center" valign="top"><img src="<?php echo $cartProduct["avatar"]?>" alt="" width="100" height="100" /></td>
										<td align="center" valign="top"><a href="/index/detail?id=<?php echo $id;?>"><?php echo $cartProduct["title"]?></a></td>
										<td align="center" valign="top" style="font-size:11px;"><?php echo number_format($cartProduct["price"])." VND" ?></td>
										<td align="center" valign="top"><input type="text" name="quantity[<?php echo $id ?>]" value="<?php echo $qty ?>" size="3" maxlength="2"/></td>
										<td align="center" valign="top" style="font-size:11px;"><?php echo number_format($qty*$cartProduct["price"])." VND" ?></td>
										<!--
										<td align="center" valign="top"><a href="/shoppingcart/index?DelProduct=<?php //echo $cartProduct["thing_id"] ?>">delete</a></td>
										-->
										<td align="center" valign="top" ><input type="submit" name="delete" onclick="return delLinkClick(this,<?php echo $id ?>,'<?php echo $this->confirm;?>')" value="<?php echo $this->text_del;?>" style="font-family:arial; font-size=10px;" /></td>	
									</tr>
				<?php
									$subTotal+=$qty*$cartProduct["price"];
								}
				?>
				<tr style="height:40px;"><!--Bottom-->
					<th colspan="4">
						<!--<a id="delBtnlink" href="/shoppingcart/index"><input type="button" name="btnDel" value="Delete" class="cart_button" /></a>-->
						<input type="submit" name="btnDel" value="<?php echo $this->text_del;?>" class="cart_button" onclick="return optionalDelele('<?php echo $this->confirm;?>')" />
						<input type="submit" name="btnReCal" value="<?php echo $this->text_recal;?>" class="cart_button" />
						<input type="button" onclick="javascript:window.location='/cart/payment?step=1'" name="btnCheckout" value="<?php echo $this->text_check;?>" class="cart_button" />
					</th>
					<th><?php echo $this->text_subtotal;?>:</th>
					<th style="font-size:11px;"><?php echo number_format($subTotal)." VND" ?></th>
					<th>&nbsp;</th>
				</tr>
				<?php
							}
						}
					}
				?>
				
				
				</table>
				
			</form>
	<?php		}?>
				<div style="clear: both;"></div>